define([ "jquery","site_tip"],  function($,Site_tip) {
	
	//require([],function(){});
	var site_tip = new Site_tip();
	function showSpace(data){
		var used_space = data.used_space;
		//var type = used_space.substring(used_space.length -2,used_space.length);
		
		var capacity = data.capacity;
		$("#space_view").find(".used").html(used_space);
		$("#space_view").find(".total").html(capacity);
		
		/*used_space = used_space.substring(0,used_space.length -2);
		
		var ctype = capacity.substring(capacity.length -2,capacity.length);
		if(type == "MB" && ctype == "GB"){
			used_space = used_space/1024;
		}
		capacity = capacity.substring(0,capacity.length -2);*/
		//console.log(data);
		var percent = data.percent*100;
		$("#space_view").find(".space_bar").width(percent+'%');
	}
	
	return {
		detail : function(){
			//site_tip.loadingMsg("");
			$.getJSON("/user/get_space",function(jsonData){
				//console.log(jsonData);
				if(!jsonData.success && jsonData.message)
				{
					site_tip.setContent(jsonData.message,true);
				}
				else if(jsonData.data)
				{
					showSpace(jsonData.data);
				}
			});
			return true;
		},
		update : function(data){
			//console.log(data);
			showSpace(data);
			return true;
		},
		updateByUuids:function(data){
			showSpace(data);
		}
	};
});